from pylons import config
from ferlons.model import meta
from sqlalchemy import Column, MetaData, Table, Integer,Unicode,DateTime
from sqlalchemy.orm import mapper, relation
from sqlalchemy import orm

def init_model(engine):
    sm = orm.sessionmaker(autoflush=True, autocommit=False, bind=engine)
    meta.engine = engine
    meta.Session = orm.scoped_session(sm)
    meta.metadata.bind = engine

usuario_table = Table('usuario', meta.metadata,
    Column('id', Integer, primary_key=True),
    Column('matricula', Unicode(20), nullable=False),
    Column('cpf', Unicode(20)),
    Column('nome', Unicode(100)),
    Column('senha', Unicode(20)),
    Column('data_admissao', DateTime()),
    Column('tipo', Integer)
)

class Usuario(object):

    def __str__(self):
        return self.matricula
    
mapper(Usuario, usuario_table)
